package cn.sibu.myroot.listview;

/**
 * Created by 刘红亮 on 15-12-18 上午9:18.
 */
public class SectionItem<T> {
    private  String mTitle;
    private  T[] mItems;

    public SectionItem(String title,T[] items){

        if(title==null){
            title = "";
        }
        mTitle = title;
        mItems = items;
    }

    public  String getTitle(){
     return  mTitle;
    }
    public  T getItem(int position){
        return  mItems[position];
    }

    public  int getCount(){
        //为节标题包含额外的项
        return (mItems == null?1:1+mItems.length);
    }

    @Override
    public boolean equals(Object o) {
        //如果两个节有相同的标题,则他们相等
        if(o!=null && o instanceof  SectionItem){
            return ((SectionItem)o).getTitle().equals(mTitle);
        }
        return false;
    }
}
